<include file="Public/header"/>
    <div class="ibox-content">
        <div class="deal-bd order-bottom">用户管理</div>
        <form class="layui-form" action=""  method="get" autocomplete="off">
            <input type="hidden" name="m" value="<{$model}>">
            <input type="hidden" name="c" value="User">
            <input type="hidden" name="a" value="index">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" class="layui-input" name="username" id="username" placeholder="商户号/用户名/姓名" lay-key="1" value="<{$_GET['username']}>">
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input style="width:200px;" type="text" class="layui-input" name="regdatetime" id="createtime" placeholder="起始时间" value="" lay-key="1">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline" style="width:200px;">
                    <select name="status">
                        <option value="">状态</option>
                        <option value="1">已激活</option>
                        <option value="0">未激活</option>
                        <option value="2">禁用</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width:200px;">
                    <select name="authorized">
                        <option value="">认证</option>
                        <option value="0">未认证</option>
                        <option value="2">等待审核</option>
                        <option value="1">认证用户</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width:200px;">
                    <select name="groupid">
                        <option value="">用户类型</option>
                        <foreach name="groupId" item="v" key="k">
                            <option value="<{$k}>"><{$v}></option>
                        </foreach>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button type="submit" class="layui-btn layui-bg-blue"><i class="fa fa-search"></i> 搜索</button>
                <button type="button" class="layui-btn layui-bg-blue add-btn" onclick="member_add('添加','<{:U('User/memberAdd',array('uid'=>$vo['id']))}>',900,800)"><i class="fa fa-user"></i> 添加用户</button>
                <button class="layui-btn layui-bg-green" onclick="exprot();return false;"><i class="fa fa-clipboard"></i> 导出数据</button>
                <button type="submit" class="layui-btn layui-bg-green"><i class="fa fa-clipboard"></i> 一键解冻</button>
            </div>
        </form>
    </div>
    <!--条件筛选过滤-->
    <div class="tablediv">
        <table class="table table-hover choosetable">
            <thead>
            <tr>
                <th></th>
                <th>商户号</th>
                <th>用户名</th>
                <th>姓名</th>
                <th>用户类型</th>
                <th>上级用户</th>
                <th>注册时间</th>
                <th>状态</th>
                <th>认证</th>
                <th>账户总额</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <volist name="list" id="vo">
            <tr>
                <td><{$vo.id}></td>
                <td><{$vo['id']|shanghubianhao=###}></a></td>
                <td><{$vo.username}></td>
                <td><{$vo.realname}></td>
                <td><{$vo.groupname}></td>
                <td><{$vo['parentid']|getParentName=###}></td>
                <td><{$vo.regdatetime|date="Y-m-d",###}></td>
                <td>
                    <input type="checkbox" class="ischange" data-uid="<{$vo.id}>" <if condition="$vo['status']">checked</if>>
                </td>
                <td>
                    <button class="layui-btn layui-btn-normal layui-btn-sm approve-btn" onclick="member_auth('用户认证','<{:U('User/authorize',['uid'=>$vo[id]])}>','600',300)">
                            <switch name="vo[authorized]" >
                                <case value="0">未认证</case>
                                <case value="1">已认证</case>
                                <case value="2">等待审核</case>
                                <default />
                            </switch>
                    </button>
                </td>
                <td>
                    <button class="layui-btn layui-btn-normal layui-btn-sm incarnate-btn" onclick="member_money('商户：<{$vo.username}>','<{:U("User/usermoney",['userid'=>$vo["id"]])}>',800,600)">可提现已冻结</button>
                </td>
                <td>
                    <button  class="btn btn-primary check-btn" onclick="member_edit('编辑','<{:U('User/editUserProduct',['uid'=>$vo[id]])}>',900,800)">查看</button>
                    <button  class="btn btn-primary" onclick="member_del(this,'<{$vo.id}>')">删除</button>
                </td>
            </tr>
            </volist>
            </tbody>
        </table>
        <!--用户列表-->
        <div class="page"><{$page}></div>
    </div>

<include file="Public/footer"/>
<script>
    layui.use(['form', 'layedit', 'laydate','layer'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        //日期时间选择器
        laydate.render({
            elem: '#createtime'
            , type: 'datetime'
            ,theme: 'molv'
            , range: '|'
        });
        //常规用法
        laydate.render({
            elem: '#birthday'
        });
        //监听表格复选框选择
        // table.on('checkbox(userData)', function(obj){
        //     var child = $(data.elem).parents('table').find('tbody input[lay-filter="ids"]');
        //     child.each(function(index, item){
        //         item.checked = data.elem.checked;
        //     });
        //     form.render('checkbox');
        // });
        //  监听radio 单选
        // form.on('radio(erweima)', function(data){
        //     console.log(data.elem); //得到radio原始DOM对象
        //     console.log(data.value); //被点击的radio的value值
        //     if(data.value==='222'){
        //         $(".sign-rule").show()
        //     }else{
        //         $(".sign-rule").hide()
        //     }
        // });
        // form.on('radio(circulation)', function(data){
        //     if(data.value==='circle'){
        //         $(".cirtable").show();
        //         $(".alone-layui-form").hide();
        //
        //     }else{
        //         $(".cirtable").hide()
        //         $(".alone-layui-form").show()
        //     }
        // });


        // form.on('switch(switchStatus)', function (data) {
        //     var isopen = this.checked ? 1 : 0,
        //         uid = $(this).attr('data-uid');
        //     $.ajax({
        //         url: "<{:U('User/editStatus')}>",
        //         type: 'post',
        //         data: "uid=" + uid + "&isopen=" + isopen,
        //         success: function (res) {
        //             if (res.status) {
        //                 layer.tips('温馨提示：开启成功', data.othis);
        //             } else {
        //                 layer.tips('温馨提示：关闭成功', data.othis);
        //             }
        //         }
        //     });
        // });
        //监听提交
        // form.on('submit(save)', function(data){
        //     $.ajax({
        //         url:"<{:U('User/saveUser')}>",
        //         type:"post",
        //         data:$('#user').serialize(),
        //         success:function(res){
        //             if(res.status){
        //                 layer.alert("编辑成功", {icon: 6},function () {
        //                     location.reload();
        //                     var index = layer.getFrameIndex(window.name);
        //                     layer.close(index);
        //                 });
        //             }else{
        //                 layer.alert("操作失败:" + res.msg, {icon: 5},function (index) {
        //                     layer.close(index)
        //                 });
        //             }
        //         }
        //     });
        //     return false;
        // });



    });
    $(".ischange").change(function() {
        var isopen = this.checked ? 1 : 0,
            uid = $(this).attr('data-uid');
        $.ajax({
            url: "<{:U('User/editStatus')}>",
            type: 'post',
            data: "uid=" + uid + "&isopen=" + isopen,
            success: function (res) {
                if (res.status) {
                    alert('温馨提示：开启成功', data.othis);
                } else {
                    alert('温馨提示：关闭成功', data.othis);
                }
            }
        });
    });



    function member_auth(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }
    // 用户-编辑
    function member_edit(title, url, id, w, h) {
        x_admin_show(title, url, w, h);
    }
    // 用户-提现
    function member_money(title, url, id, w, h) {
        x_admin_show(title, url, w, h);
    }

    function member_add(title, url, id, w, h) {
        x_admin_show(title, url, w, h);
    }

    function exprot(){
        window.location.href
            ="<{:U('Admin/User/exportuser',array('username'=>$_GET[username],'parentid'=>$_GET[parentid],'status'=>$_GET[status],'authorized'=>$_GET[authorized],'groupid'=>$_GET[groupid],'regdatetime'=>$_GET[regdatetime]))}>";
    }

    /*用户-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                url:"<{:U('User/delUser')}>",
                type:'post',
                data:'uid='+id,
                success:function(res){
                    if(res.status){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }
                }
            });
        });
    }

    function thawing_funds(){
        layer.confirm('温馨提示：解冻数据数量多，可能需要时间非常长，请尽量在交易量低的时间段再提交，<br><br>确认要提交吗？',function(index) {
            layer.load();
            $.ajax({
                'url':'<{:U("User/thawingFunds")}>',
                '':'json',
                'type':'get',
                'success':function(info){
                    console.log(info);
                    layer.closeAll('loading');
                    layer.msg(info['msg'], {icon: 1, time: 1000},function () {
                        location.replace(location.href);
                    }); 
                },
                'error':function(){

                },
            });
        });
    }
    $('#export').on('click',function(){
        window.location.href
            ="<{:U('Admin/User/exportuser',array('username'=>$_GET[username],'parentid'=>$_GET[parentid],'status'=>$_GET[status],'authorized'=>$_GET[authorized],'groupid'=>$_GET[groupid],'regdatetime'=>$_GET[regdatetime]))}>";
    });
</script>
</body>
</html>